package com.zhouzhou.fastjava.tree;

import java.util.List;
import java.util.Set;
import java.util.TreeSet;


public abstract class TreeNode<T> implements Comparable<T> {

    private Set<T> children = new TreeSet<T>();

    private boolean expanded;

    public abstract String getId();

    public abstract String getText();

    public boolean isExpanded() {
        return expanded;
    }

    public boolean isLeaf() {
        return getChildren() == null || getChildren().isEmpty();
    }

    public Set<T> getChildren() {
        return children;
    }

    public void addChild(T t) {
        children.add(t);
    }

    public void addChildren(List<T> list) {
        children.addAll(list);
    }

    public void setExpanded(boolean isExpanded) {
        this.expanded = isExpanded;
    }

}
